<?php

class AdminQLNguoiDung extends BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
       return View::make('quantri.qlnd')->with('title','Quản lý người dùng');
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
        return View::make('adminqlnguoidungs.create');
	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
        return View::make('adminqlnguoidungs.show');
	}

	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
        return View::make('adminqlnguoidungs.edit');
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}
	public function lay_thong_tin_nguoi_dung()
	{
		$array = DB::table('nguoi_dung')
			->join('nhom_quyen_han', function ($join) 
				{
					$join->on('nhom_quyen_han.id','=','nguoi_dung.id_nhom_quyen');
				}) 			
			->select('nguoi_dung.tai_khoan','nhom_quyen_han.mo_ta_nhom_quyen',
					'nguoi_dung.hoat_dong','nguoi_dung.id')
			->paginate(SV_PERPAGE);
		return $array;							
	}
	public function khoa_nguoi_dung()
	{
		$idnguoidung = Input::get('txtIDNguoiDung');
		$array = DB::table('nguoi_dung')
			->where('id','=',$idnguoidung)		
			->update(array(
				'hoat_dong' => '0'));
		return Redirect::back()->with('ketquakhoa',$array);							
	}
	public function mo_khoa_nguoi_dung()
	{
		$idnguoidung = Input::get('txtIDNguoiDung');
		$array = DB::table('nguoi_dung')
			->where('id','=',$idnguoidung)		
			->update(array(
				'hoat_dong' => '1'));
		return Redirect::back()->with('ketquamokhoa',$array);							
	}
}
